package com.supreme.simpleserver.service;

import com.supreme.commonmybatis.mapper.StorageMapper;
import com.supreme.commonmybatis.entity.primary.MBStorage;
import com.supreme.commonboot.exception.BizException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class SeataService {

    @Resource
    private StorageMapper storageMapper;

    public int testZero(int status) {
        return status;
    }

    @Transactional
    public MBStorage createStorage(MBStorage storage) {
        int insert = this.storageMapper.insert(storage);
        if (insert == 1) {
            System.out.println("createStorage: " + insert);
            throw new BizException("createStorage exception");
        }
        return storage;
    }
}
